﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>opencti</title>
		<link rel="stylesheet" href="css/reset.css" type="text/css"
			media="all" />
		<link rel="stylesheet" type="text/css">
		<link href="css/softptool.css" rel="stylesheet" type="text/css"
			media="all" />
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/json2.js?t=20171226"></script>
		<script type="text/javascript" src="js/interaction-util.js?t=20171226"></script>
		<script type="text/javascript" src="../softphone_voice.js?t=20171226"></script>
		<script type="text/javascript" src="../interaction-event.js?t=20171226"></script>
		<script type="text/javascript" src="../interaction-callback-voice.js?t=20171226"></script>
        <script type="text/javascript">
				    //<!-- 禁用右键: --> 
					function stop(){ 
					  return false; 
					} 
					document.oncontextmenu=stop;
		</script>
		<script>
		
			var userid = '';
			var clientId = '123';
			var connId1 = "";
			var connId2 = "";
		
			/**
			 * 收到CRM父页面传来的消息,和CRM集成
			 */
			window.addEventListener('message', function(e) {
				if (e.source != window.parent)
					return;
				var loginCode = '';
				var result = new Object();
				var errorcode = '';
				//log("window.addEventListener message is:",e.data);
				try {
					if (e.data.operation == 'init') {
						//place, loginCode, queue, channel
					var place = e.data.place;
					var loginCode = e.data.loginCode;
					var queue = e.data.queue;
					var channel = e.data.channel;
					init(place, loginCode, queue, channel);
					loginCode = 'init';
				} else if (e.data.operation == 'loggedOut') {
					logout1();
					loginCode = 'loggedOut';
				} else if (e.data.operation == 'notReady') {
					var channel = e.data.channel;
					var reasonCode = e.data.reasonCode;
					notReady1(reasonCode);
				} else if (e.data.operation == 'ready') {
					var channel = e.data.channel;
					//var reasonCode = e.data.reasonCode;
					ready1();
				} else if (e.data.operation == 'Reject') {
					var connId_chat = e.data.connId;
					reject(connId_chat);
					loginCode = 'Reject';
				} else if (e.data.operation == 'complete') {
					var connId_chat = e.data.connId;
					var queueName = e.data.queueName;
					complete(connId_chat, queueName);
					loginCode = 'complete';
				}else if (e.data.operation == 'diaCall') {
					var phoneNum = e.data.phoneNum;
					makeCall1(phoneNum);
					errorcode = 'diaCall';
				}
			} catch (e) {
				console.log(e);
			}
			if (loginCode == '' | loginCode == null) {
				if (result == '' || result == null || result == 'undefined') {
					var obj = new Object();
					obj.statusCode = 1;
					obj.statusMessage = "获取数据为空";
					obj.operation = errorcode;
					result = obj;
				}
		
				window.parent.postMessage(result, '*');
			}
		}, false);


	function testLogin() {
		var loginId = $("#loginId").val();
		var place = $("#place").val();
		if (loginId == '' || loginId == null) {
			alert("请填写工号！");
			return false;
		}
		if (place == '' || place == null) {
			alert("请填写Place！");
			return false;
		}
		//window.parent.popScreen("");
		init(place, loginId, '', '["voice"]');
	}
	function clearLog() {
		//alert("123");
		document.getElementById("responses").innerHTML = ""
	}

	function removeAllSpace(obj) {
		obj.value = obj.value.replace(/\s+/g, "");
	}

	function RunOnBeforeUnload() {
		logout1();
	}
</script>
</head>
<body onbeforeunload="RunOnBeforeUnload()">
	<div id="header">

		<div class="softtool">
			<div class="softtool-btns">
				<ul class="softtool-btns-list">
					<li class="readybnts disable" id="btnLogin">签入</li>
					<li class="readybnts disable" id="btnLogout">签出</li>
					<li class="readybnts disable" id="btnReady">示闲</li>
					<li class="readybnts disable" id="btnNotReady">示忙</li>
					<li class="phoneanswer" style="position: relative;"><img
						id="answer" src="images/btns_answer_disable.png"
						style="position: absolute; opacity: 1; left: 17px" /></li>
					<li class="phonerefuse" style="margin-left: 57px"><img
						id="refuse" src="images/btns_refuse_disable.png" /></li>
					<li>
						<div class="numkeys-opt">
							<div class="numkeys-opt-view">
								<input type="text" value=""  onchange="removeAllSpace(this)" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"  onkeydown="if(event.keyCode==32 || event.keyCode==9) return false" id="phoneNo" />
								<div class="numkeys-opt-answer">
									<img id="btnCall" src="images/btns-k-answer-disabled.png" />
								</div>
							</div>
						</div>
					</li>
					<li class="btns-tab sound" style='display: none'><img
						src="images/btns-soundno.png" /></li>
				</ul>
				<div class="clear"></div>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	<pre style="height: 350px; overflow: scroll;" id="responses"></pre>
	<div>
		工号：<input type="text" id="loginId" value="10001" /> Place：<input
			type="text" id="place" value="6001" /> <input type="button"
			onclick="testLogin();" value="LOGIN" /> <input type="button"
			onclick="clearLog();" value="CLEARLOG" />
	</div>
</body>
</html>